package com.yshebkb.sulp.job;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * @author heys
 * @date 2018/9/27.
 */
public class ThreadTest extends Thread implements Runnable{

    private String name;
    private String src;
    private String target;

    private String result;

    public ThreadTest(String name, String src, String target) {
        this.name = name;
        this.src = src;
        this.target = target;
    }

    @Override
    public void run() {
        int sleep = new Random().nextInt(10);
        try {
            TimeUnit.SECONDS.sleep(sleep);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + ", 耗时: " + sleep + "s");
        this.result = String.format("%s company from %s to %s", this.name, this.src, this.target);
    }

    public String getResult() {
        return result;
    }
}
